package com.zc.edu.controller;


import com.zc.edu.entity.subject.SubjectTreeItem;
import com.zc.edu.service.SubjectService;
import com.zc.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author cong
 * @since 2022-11-24
 */
@RestController
@RequestMapping("/eduService/subject")
@CrossOrigin
public class SubjectController {

	@Autowired
	private SubjectService subjectService;

	@PostMapping("/addSubject")
	public R addSubject(MultipartFile file) {
		subjectService.saveSubject(file, subjectService);
		return R.ok();
	}

	@GetMapping("/getAllSubject")
	public R getAllSubject() {
		List<SubjectTreeItem> subjectTreeItems = subjectService.getTreeSubject();
		return R.ok().data("tree", subjectTreeItems);
	}
}

